package com.tjc.media.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.tjc.media.domain.VideoAuth;
import com.tjc.media.service.IVideoAuthService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频授权播放Controller
 * 
 * @author 大根教会
 * @date 2025-07-10
 */
@RestController
@RequestMapping("/media/videoAuth")
public class VideoAuthController extends BaseController
{
    @Autowired
    private IVideoAuthService videoAuthService;

    /**
     * 查询视频授权播放列表
     */
    @PreAuthorize("@ss.hasPermi('media:videoAuth:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoAuth videoAuth)
    {
        startPage();
        List<VideoAuth> list = videoAuthService.selectVideoAuthList(videoAuth);
        return getDataTable(list);
    }

    /**
     * 导出视频授权播放列表
     */
    @PreAuthorize("@ss.hasPermi('media:videoAuth:export')")
    @Log(title = "视频授权播放", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoAuth videoAuth)
    {
        List<VideoAuth> list = videoAuthService.selectVideoAuthList(videoAuth);
        ExcelUtil<VideoAuth> util = new ExcelUtil<VideoAuth>(VideoAuth.class);
        util.exportExcel(response, list, "视频授权播放数据");
    }

    /**
     * 获取视频授权播放详细信息
     */
    @PreAuthorize("@ss.hasPermi('media:videoAuth:query')")
    @GetMapping(value = "/{authId}")
    public AjaxResult getInfo(@PathVariable("authId") Long authId)
    {
        return success(videoAuthService.selectVideoAuthByAuthId(authId));
    }

    /**
     * 新增视频授权播放
     */
    @PreAuthorize("@ss.hasPermi('media:videoAuth:add')")
    @Log(title = "视频授权播放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoAuth videoAuth)
    {
        return toAjax(videoAuthService.insertVideoAuth(videoAuth));
    }

    /**
     * 修改视频授权播放
     */
    @PreAuthorize("@ss.hasPermi('media:videoAuth:edit')")
    @Log(title = "视频授权播放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoAuth videoAuth)
    {
        return toAjax(videoAuthService.updateVideoAuth(videoAuth));
    }

    /**
     * 删除视频授权播放
     */
    @PreAuthorize("@ss.hasPermi('media:videoAuth:remove')")
    @Log(title = "视频授权播放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{authIds}")
    public AjaxResult remove(@PathVariable Long[] authIds)
    {
        return toAjax(videoAuthService.deleteVideoAuthByAuthIds(authIds));
    }
}
